package com.mera.tektronix.csviewer.services



import grails.test.mixin.*

import org.junit.*

import com.mera.tektronix.csviewer.domain.*
import com.mera.tektronix.csviewer.transformers.*

/**
 * See the API for {@link grails.test.mixin.services.ServiceUnitTestMixin} for usage instructions
 */
@TestFor(CompanyRemoteService)
@Mock([Company])
class CompanyRemoteServiceTests {

   void testGetElement() {
	   defineBeans {
		   companyTransformer(CompanyTransformer)
	   }
	   
		Company company = new Company(id: 1, name: "Mera", email: "mera@mera.ru", address:"Nizhny Novgorod, Delovaya 13", phone: "278-88-88").save(validate: false)

		def elem = service.getCompanyById(1)
		
		assert elem.id == 1
		assert elem.name == "Mera"
		assert elem.email == "mera@mera.ru"
		assert elem.address == "Nizhny Novgorod, Delovaya 13"
		assert elem.phone == "278-88-88"
		
		elem = service.getCompanyByName("Mera")
		
		assert elem.id == 1
		assert elem.name == "Mera"
		assert elem.email == "mera@mera.ru"
		assert elem.address == "Nizhny Novgorod, Delovaya 13"
		assert elem.phone == "278-88-88"
	}
}
